import {JsonAsset, Prefab, resources} from "cc";

export class ResourcesUtil {
    public static loadPrefab(url: string): Promise<Prefab> {
        return new Promise((resolve, reject) => {
            resources.load(url, Prefab, (err, asset) => {
                err ? reject(err) : resolve(asset);
            });
        })
    }
    public static loadJson(url: string): Promise<Record<string, any>> {
        return new Promise((resolve, reject) => {
            resources.load(url, JsonAsset, (err, asset) => {
                err ? reject(err) : resolve(asset.json);
            });
        })
    }
}